import * as ActionTypes from './type'

export default {
  [ActionTypes.SAVE_DESIGN_SRC]: (state, data) => {
    if (!state.design) {
      let design = {
        iframeSrc: data
      }
      state.design = design
    } else {
      let design = JSON.parse(JSON.stringify(state.design))
      design.iframeSrc = data
      state.design = design
    }
  },
  [ActionTypes.SAVE_DESIGN_REF]: (state, data) => {
    let design = JSON.parse(JSON.stringify(state.design))
    design.ref = data
    state.design = design
  },
  [ActionTypes.SAVE_DESIGN_PAGE_ID]: (state, data) => {
    let design = JSON.parse(JSON.stringify(state.design))
    design.pageId = data
    state.design = design
  },
  [ActionTypes.REFRESH_PAGE]: (state, data) => {
    let design = JSON.parse(JSON.stringify(state.design))
    design.refresh = data ? 1 : 0
    state.design = design
  }
}
